package testcases;

import java.util.ArrayList;
import java.util.Hashtable;

import org.junit.Test;

import def.Protein;
import def.TSpan;


public class CorefProteinTest {
	@Test public void test(){
		ArrayList<Protein> proteins = new ArrayList<Protein>();
		Protein p1 = new Protein();
		p1.tspan = new TSpan();
		p1.tspan.tid = "t1";
		p1.tspan.startIdx = 0;
		p1.tspan.endIdx = 8;
		Protein p2 = new Protein();
		p2.tspan = new TSpan();
		p2.tspan.tid = "t2";
		p2.tspan.startIdx = 11;
		p2.tspan.endIdx = 13;
		proteins.add(p1);
		proteins.add(p2);
		String text = "receptor (hMR)";
		System.err.println(text.length());
		Hashtable<String, Protein> corefProteins = new Hashtable<String,Protein>();
		if (proteins.size()>1){
			for (int i = 0; i < proteins.size() -1; i++){
				if (proteins.get(i).tspan.endIdx+4 >= proteins.get(i+1).tspan.startIdx
						&& text.charAt(proteins.get(i).tspan.endIdx+1) == '('
							&& text.charAt(proteins.get(i+1).tspan.endIdx) == ')'){
					if (proteins.get(i).tspan.endIdx-proteins.get(i).tspan.startIdx > 
					proteins.get(i+1).tspan.endIdx - proteins.get(i+1).tspan.startIdx){
						corefProteins.put(proteins.get(i).tspan.tid, proteins.get(i+1));
					}
					else{
						corefProteins.put(proteins.get(i+1).tspan.tid, proteins.get(i+1));
					}
					i++;
				}
			}
		}
		System.err.println("[COREF_PROTEINS] from "+proteins);
		System.err.println("[COREF_PROTEINS] found "+corefProteins);

	}
}
